﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HZ.Data;
using System.Data;
using System.Data.SqlClient;
using HZ.BidSystem.Model;

namespace HZ.BidSystem.DAL
{
    public class DAL_Project
    {
        public static IList<HZ.BidSystem.Model.Project> GetProjectList()
        {
            return DAL_Helper.CommonFillList<Project>(HZ.Data.DbHelperFactory.Create().ExecuteTable("SELECT * FROM TB_Project"));
        }

        public static Project GetProjectInfoById(int ProjectId)
        {
            string sql = "SELECT * FROM TB_Project WHERE ProjectId = @ProjectId";
            IDataParameter para = new SqlParameter("@ProjectId", ProjectId);
            DataTable dt = HZ.Data.DbHelperFactory.Create().ExecuteTable(CommandType.Text, sql, para);
            if (dt.Rows.Count > 0)
            {

                return DAL_Helper.CommonFill<Project>(dt.Rows[0]);
            }
            else
            {
                return null;
            }
        }

        public static ProjectConfig GetProjectConfigById(int projectid)
        {
            string sql = "SELECT * FROM TB_ProjectConfig WHERE ProjectId = @ProjectId";
            IDataParameter para = new SqlParameter("@ProjectId", projectid);
            DataTable dt = HZ.Data.DbHelperFactory.Create().ExecuteTable(CommandType.Text, sql, para);
            if (dt.Rows.Count > 0)
            {

                return DAL_Helper.CommonFill<ProjectConfig>(dt.Rows[0]);
            }
            else
            {
                return null;
            }
        }


    }
}
